Day 10 - Sorting and reducing

33

$ seq 1 20 | sort

1

10

11

12

13

14

15

16

17

18

19

2

20

3

4

5

6

7

8

9

We probably want sort to understand that 9 comes before 10. This can be done with the -n option,

which implements the numeric sort.

$ seq 1 20 | sort -n

1

2

3

4

[...]

The default sorting order used by the command is ascending, that is following the alphabet (or the

value of the numbers). To show the sorted list in reverse order we can use the -r option

$ cat examples.txt | sort -r

which can be combined with -n to reverse a numerical sort